package menu

import (
	"context"
	"go-zero-project/common/ctxdata"
	"go-zero-project/common/response"
	"net/http"

	"go-zero-project/services/user/api/internal/logic/menu"
	"go-zero-project/services/user/api/internal/svc"
)

func NavigationHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		// token放在上下文里面
		ctx := r.Context()
		jwtUserId := w.Header().Get(ctxdata.CtxKeyJwtUserId)
		ctx = context.WithValue(ctx, ctxdata.CtxKeyJwtUserId, jwtUserId)
		// 调用接口
		l := menu.NewNavigationLogic(ctx, svcCtx)
		resp, err := l.Navigation()
		response.Response(w, resp, err)
	}
}
